package com.ruoyi.cpsp.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.cpsp.domain.Employee;
import com.ruoyi.cpsp.domain.EmployeeEntity;
import lombok.Builder;
import org.apache.ibatis.annotations.Param;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface EmployeeMapper extends BaseMapper<Employee> {
    int deleteByPrimaryKey(@Param("id") Integer id);

    int deleteByDepart(@Param("departmentId")String departmentId, @Param("state") Integer state);

    int insertSelective(Employee record);

    EmployeeEntity selectByPrimaryKey(@Param("id") Integer id);

    EmployeeEntity selectByCard(@Param("idCard") String idCard);

    EmployeeEntity selectByJobNumber(@Param("jobNumber") String jobNumber);

    int updateByPrimaryKeySelective(Employee record);

    int updateByPrimaryKey(Employee record);

    EmployeeEntity getById(@Param("id") Integer id);

    List<String> selectCardByDepart(@Param("department") String department, @Param("teamGroupId") Integer teamGroupId);

    List<EmployeeEntity> findEmployees(@Param("departmentId") String departmentId,
                                       @Param("teamGroupId") String teamGroupId,
                                       @Param("name") String name);

    List<EmployeeEntity> selectAll();

    List<EmployeeEntity> selectSelective(@Param("department") String department,
                                         @Param("teamGroup") Integer teamGroup,
                                         @Param("employeeInfo") String employeeInfo);

    List<EmployeeEntity> selectInfoSelective(@Param("department") String department,
                                             @Param("teamGroup") String teamGroup,
                                             @Param("isDirectProducer") Integer isDirectProducer,
                                             @Param("name") String name);

    /**
     * 获取某班组的员工列表
     * @return
     */
    List<EmployeeEntity> selectEmployeesByTeamGroup(@Param("teamGroup") String teamGroup,
                                                    @Param("department") String department);

    /**
     * 获取某部门员工列表
     * @return
     */
    List<EmployeeEntity> selectEmployeesByDepartment(@Param("department") String department);

    List<EmployeeEntity> selectByName(@Param("name") String name, @Param("state")Integer state);

//    /**
//     * 根据年份和季度获取是否满 45 天的情况
//     * @param year
//     * @param quarter
//     * @return
//     */
//    List<Boolean> selectIs45DaysByYearAndQuarter(@Param("year") Integer year, @Param("quarter") Integer quarter);

    /**
     * 获取某员工是否是 45 天的信息
     * @param idCard
     * @return
     */
    Boolean getIs45Days(String idCard);

    /**
     * 获取某员工是否是直接生产者
     * @param idCard
     * @return
     */
    Boolean getIsDirectProducer(@Param("idCard") String idCard);

    Integer updateTeamGroup(@Param("teamGroupId")Integer teamGroupId);

    List<EmployeeEntity> selectEmployeeByValue(@Param("perValue") double perValue);

    // 用来控制该员工状态，状态为2——离职
    Integer updateEmployeeState(@Param("id") Integer id, @Param("state") Integer state);
}

